package com.backend.common;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PageResponse implements Serializable {
    private static final long serialVersionUID = 1L;


    // 总记录数
    private long total;

    // 每页记录数
    private long pageSize;

    // 总页数
    private long totalPage;

    // 当前页数
    private long currentPage;

    //列表数据
    private List<?> list;

    public PageResponse(List<?> list, int total, int pageSize, int currentPage) {
        this.list = list;
        this.totalPage = total;
        this.pageSize = pageSize;
        this.currentPage = currentPage;
        this.totalPage = (long)Math.ceil((double)total / pageSize);
    }

    public PageResponse(Page<?> page) {
        this.list = page.getRecords();
        this.total = page.getTotal();
        this.pageSize = page.getSize();
        this.currentPage = page.getCurrent();
        this.totalPage = page.getPages();
    }



}









